﻿<UserControl x:Class="Albatross.SSRSViewer.Views.ReportViewerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:commonViews="clr-namespace:Albatross.WPF.Common.Views;assembly=Albatross.WPF.Common"
			 xmlns:vm="clr-namespace:Albatross.SSRSViewer.ViewModels"
			 xmlns:winForm="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"
			 xmlns:controls="clr-namespace:Albatross.WPF.Common.Controls;assembly=Albatross.WPF.Common"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800">
	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/Albatross.Resources;component/toolbar.xaml"/>
			</ResourceDictionary.MergedDictionaries>
			
			<commonViews:BooleanVisibilityConverter x:Key="bool2visibility" />
			<commonViews:NotConverter x:Key="notcvt"/>
			
			<Style TargetType="TreeViewItem" x:Key="tree view item">
				<Setter Property="FontFamily" Value="Segoe UI"/>
				<Setter Property="FontSize" Value="12" />
				<Setter Property="Margin" Value="0"/>
				<Setter Property="Padding" Value="0"/>
				<Setter Property="Foreground" Value="Black"/>
				<Setter Property="FontWeight" Value="Normal"/>
				<Setter Property="BorderThickness" Value="0"/>
				<Setter Property="VerticalContentAlignment" Value="Center"/>
				<Setter Property="BorderBrush" Value="Silver"/>
				<Setter Property="Background" Value="White"/>
				<Setter Property="IsExpanded" Value="{Binding IsExpanded}"/>
				<Setter Property="Visibility" Value="{Binding Visible, Converter={StaticResource bool2visibility}}"/>
				<Setter Property="ToolTip" Value="{Binding Description}" />
				<EventSetter Event="MouseDoubleClick" Handler="TreeViewItem_DoubleClick" />
			</Style>
			
			<HierarchicalDataTemplate x:Key="tree view item template" ItemsSource="{Binding Children}" DataType="{x:Type vm:ReportItemViewModel}" ItemContainerStyle="{StaticResource tree view item}">
				<DockPanel>
					<Image>
						<Image.Style>
							<Style TargetType="Image">
								<Setter Property="Width" Value="16"/>
								<Setter Property="Height" Value="16"/>
								<Setter Property="Margin" Value="2 0 0 0" />
								<Style.Triggers>
									<DataTrigger Binding="{Binding Type}" Value="DataSource">
										<Setter Property="Source" Value="/Albatross.Resources;component/Images/dataSource.png"/>
									</DataTrigger>
									<DataTrigger Binding="{Binding Type}" Value="Folder">
										<Setter Property="Source" Value="/Albatross.Resources;component/Images/folder.png"/>
									</DataTrigger>
									<DataTrigger Binding="{Binding Type}" Value="Report">
										<Setter Property="Source" Value="/Albatross.Resources;component/Images/report.png"/>
									</DataTrigger>
									<DataTrigger Binding="{Binding Type}" Value="LinkedReport">
										<Setter Property="Source" Value="/Albatross.Resources;component/Images/linked report.png"/>
									</DataTrigger>
								</Style.Triggers>
							</Style>
						</Image.Style>
					</Image>
					<TextBlock Text="{Binding Name}" Padding="3" />
				</DockPanel>
			</HierarchicalDataTemplate>

			<DataTemplate x:Key="left header template">
				<Border BorderBrush="Silver" BorderThickness="1">
					<DockPanel DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=controls:AlbatrossDockPanel}}">
						<ToggleButton Style="{StaticResource collapse btn}" />
						<ToolBar Style="{StaticResource toolbar}" IsEnabled="{Binding IsLoading, Converter={StaticResource notcvt}}">
							<Button Command="{Binding RefreshCommand}">
								<DockPanel>
									<Image Source="/Albatross.Resources;component/Images/refresh.png" Style="{StaticResource toolbar img}"/>
									<TextBlock Style="{StaticResource toolbar text}">Refresh</TextBlock>
								</DockPanel>
							</Button>
							<Menu Style="{StaticResource toolbar menu}">
								<MenuItem Margin="0" Padding="2" VerticalAlignment="Stretch">
									<MenuItem.HeaderTemplate>
										<DataTemplate>
											<DockPanel>
												<Image Source="/Albatross.Resources;component/Images/new.png" Style="{StaticResource toolbar img}"/>
												<TextBlock Style="{StaticResource toolbar text}">New</TextBlock>
											</DockPanel>
										</DataTemplate>
									</MenuItem.HeaderTemplate>

									<MenuItem Header="New Tab" Command="{Binding NewTabCommand}">
										<MenuItem.Icon>
											<Image Source="/Albatross.Resources;component/Images/new tab.png" Style="{StaticResource toolbar menuitem img}"/>
										</MenuItem.Icon>
									</MenuItem>

									<MenuItem Header="New Window" Command="{Binding NewWindowCommand}">
										<MenuItem.Icon>
											<Image Source="/Albatross.Resources;component/Images/expand.png" Style="{StaticResource toolbar menuitem img}"/>
										</MenuItem.Icon>
									</MenuItem>
								</MenuItem>
							</Menu>
							<Menu Style="{StaticResource toolbar menu}">
								<MenuItem Margin="0" Padding="2" VerticalAlignment="Stretch">
									<MenuItem.HeaderTemplate>
										<DataTemplate>
											<DockPanel>
												<Image Source="/Albatross.Resources;component/Images/visibility.png" Style="{StaticResource toolbar menuitem img}"/>
												<TextBlock Style="{StaticResource toolbar text}">Visibility</TextBlock>
											</DockPanel>
										</DataTemplate>
									</MenuItem.HeaderTemplate>
									<MenuItem Header="Empty Folder" IsCheckable="True" IsChecked="{Binding ShowEmptyFolder}"/>
									<MenuItem Header="Data Source" IsCheckable="True" IsChecked="{Binding ShowDataSource}"/>
									<MenuItem Header="Report" IsCheckable="True" IsChecked="{Binding ShowReport}"/>
									<MenuItem Header="Other" IsCheckable="True" IsChecked="{Binding ShowOther}" />
								</MenuItem>
							</Menu>
							<Menu Style="{StaticResource toolbar menu}">
								<MenuItem Margin="0" Padding="2" VerticalAlignment="Stretch">
									<MenuItem.HeaderTemplate>
										<DataTemplate>
											<DockPanel>
												<Image Source="/Albatross.Resources;component/Images/toggle.png" Style="{StaticResource toolbar menuitem img}"/>
												<TextBlock Style="{StaticResource toolbar text}">Toggle</TextBlock>
											</DockPanel>
										</DataTemplate>
									</MenuItem.HeaderTemplate>

									<MenuItem Header="Expand" Command="{Binding ExpandAllCommand}">
										<MenuItem.Icon>
											<Image Source="/Albatross.Resources;component/Images/expand.png" Style="{StaticResource toolbar menuitem img}"/>
										</MenuItem.Icon>
									</MenuItem>

									<MenuItem Header="Collpase" Command="{Binding CollapseAllCommand}">
										<MenuItem.Icon>
											<Image Source="/Albatross.Resources;component/Images/collapse.png" Style="{StaticResource toolbar menuitem img}"/>
										</MenuItem.Icon>
									</MenuItem>
								</MenuItem>
							</Menu>
						</ToolBar>
					</DockPanel>
				</Border>
			</DataTemplate>

			<DataTemplate x:Key="left collapse bar template">
				<Border Background="LightBlue">
					<ToggleButton Style="{StaticResource expand btn}" />
				</Border>
			</DataTemplate>
		</ResourceDictionary>
		
	</UserControl.Resources>

	<controls:AlbatrossDockPanel DockLeft="True" DockBottom="False" DockTop="False" DockRight="False" IsLeftExpanded="True" 
								 LeftHeaderTemplate="{StaticResource left header template}" LeftCollapseBarTemplate="{StaticResource left collapse bar template}" LeftDragStarted="AlbatrossDockPanel_LeftDragStarted" LeftDragCompleted="AlbatrossDockPanel_LeftDragCompleted" >
		<controls:AlbatrossDockPanel.Left>
			<Grid>
				<DockPanel IsEnabled="{Binding IsLoading, Converter={StaticResource notcvt}}">
					<DockPanel DockPanel.Dock="Top" KeyboardNavigation.TabNavigation="Cycle">
						<TextBlock Margin="5 2 5 2" VerticalAlignment="Center">Filter:</TextBlock>
						<Button Background="Transparent" DockPanel.Dock="Right" Margin="0 5 5 5" Command="{Binding ClearFilterCommand}" TabIndex="2">
							<Image Width="16" Height="16" Source="/Albatross.Resources;component/Images/clear.png"/>
						</Button>
						<TextBox Margin="2 5 2 5" Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged}" BorderBrush="Silver" BorderThickness="1" TabIndex="1"/>
					</DockPanel>
					<TreeView x:Name="Tree" 
						  ItemsSource="{Binding Items}" 
						  ItemContainerStyle="{StaticResource tree view item}" 
						  ItemTemplate="{StaticResource tree view item template}" 
						  BorderThickness="0" 
						  Background="Transparent">
						<TreeView.InputBindings>
							<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding OpenCommand}" CommandParameter="{Binding Path=(commonViews:Attached.ViewService), ElementName=Tree}" />
						</TreeView.InputBindings>
					</TreeView>
				</DockPanel>
				<commonViews:LoadingView Visibility="{Binding IsLoading, Converter={StaticResource bool2visibility}}" />
			</Grid>
		</controls:AlbatrossDockPanel.Left>
		<WindowsFormsHost x:Name="WinFormHost" Grid.Column="2">
			<winForm:ReportViewer Dock="Fill" x:Name="ReportViewer" 
								  ProcessingMode="Remote"  
								  BorderStyle="None" 
								  ShowToolBar="True" />
		</WindowsFormsHost>
	</controls:AlbatrossDockPanel>
</UserControl>
